package org.example.contestb.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import jakarta.annotation.Resource;
import org.example.contestb.entity.DTO.BanDTO;
import org.example.contestb.entity.DTO.MessStatusDTO;
import org.example.contestb.entity.DTO.UpdateDoctorDTO;
import org.example.contestb.entity.Doctor;
import org.example.contestb.entity.Message;
import org.example.contestb.entity.Patient;
import org.example.contestb.entity.VO.MessageVO;
import org.example.contestb.entity.VO.RoughlyDoctorVO;
import org.example.contestb.responce.R;
import org.example.contestb.service.AdminService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.print.Doc;
import java.util.List;

@RestController
@RequestMapping("/admin")
public class AdminController {
    @Resource
    AdminService adminService;

    @SaCheckLogin
    @GetMapping("/messageDisplay")
    public R messageDisplay(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "5") Integer pageSize
    ){
        MessageVO messageVO = adminService.messageDisplay(page,pageSize);
        return R.success(messageVO);
    }

    @SaCheckLogin
    @PostMapping("/messageSolving")
    public R messageSolving(@RequestBody @Validated MessStatusDTO statusDTO){
        return R.success(adminService.messageSolving(statusDTO));
    }

    @SaCheckLogin
    @GetMapping("/display")
    public R Display(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "5") Integer pageSize
    ){
        RoughlyDoctorVO roughlyDoctorVO = adminService.display(page,pageSize);
        return R.success(roughlyDoctorVO);
    }

    @SaCheckLogin
    @GetMapping("/search")
    public R patientSearch(@RequestParam String name){
        List<Doctor> list = adminService.doctorSearch(name);
        return R.success(list);
    }

    @SaCheckLogin
    @PostMapping("/ban")
    public R doctorBanning(@RequestBody @Validated BanDTO banDTO){
        return R.success(adminService.doctorBanning(banDTO));
    }

    @SaCheckLogin
    @PostMapping("/disban")
    public R doctorDisbanning(@RequestBody @Validated BanDTO banDTO){
        return R.success(adminService.doctorDisbanning(banDTO));
    }

    @SaCheckLogin
    @DeleteMapping("/delete")
    public R doctorDelete(@RequestBody @Validated BanDTO banDTO){
        return R.success(adminService.doctorDelete(banDTO));
    }

    @SaCheckLogin
    @PutMapping("/update")
    public R doctorUpdate(@RequestBody @Validated UpdateDoctorDTO updateDoctorDTO){
        return R.success(adminService.doctorUpdate(updateDoctorDTO));
    }
}
